﻿<Window x:Class="PingPong.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:ns="clr-namespace:PingPong"
    Title="Ping pong" Height="500" Width="400" Closing="Window_Closing" 
    WindowStyle="None" ResizeMode="NoResize" AllowsTransparency="True" 
    Background="Transparent" MouseLeftButtonDown="Window_MouseLeftButtonDown" WindowStartupLocation="CenterScreen">
    <Window.Resources>
        <Style x:Key="TextStyle" TargetType="{x:Type TextBlock}">
            <Setter Property="FontSize" Value="11"/>
            <Setter Property="FontFamily" Value="Tahoma"/>
            <Setter Property="Foreground" Value="#FF4E4E4E"/>
        </Style>
    </Window.Resources>
    <Grid>
        <Rectangle Fill="#FFF3F7FA" RadiusX="8" RadiusY="8" StrokeThickness="2" Stroke="#FFA5CCE3" Grid.RowSpan="6"/>

        <DockPanel VerticalAlignment="Stretch" Margin="10">
           <TextBlock Text="Ping pong" TextAlignment="Center" DockPanel.Dock="Top" 
                      Style="{StaticResource TextStyle}" FontSize="16" FontWeight="Bold"/>
        
           <Grid Margin="0,10,0,0" VerticalAlignment="Stretch">
               <Grid.RowDefinitions>
                  <RowDefinition Height="Auto"/>
                  <RowDefinition Height="Auto"/>
                  <RowDefinition Height="Auto"/>
                  <RowDefinition Height="*"/>
                  <RowDefinition Height="*"/>
                  <RowDefinition Height="Auto"/>
               </Grid.RowDefinitions>
            
               <Grid Margin="5">
                    <Grid.RowDefinitions>
                        <RowDefinition/>
                        <RowDefinition Height="5"/>
                        <RowDefinition/>
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" MinWidth="105" />
                        <ColumnDefinition/>
                    </Grid.ColumnDefinitions>
            <TextBlock Text="Enter search string:" VerticalAlignment="Center" HorizontalAlignment="Left" Style="{StaticResource TextStyle}"/>
            <TextBox HorizontalAlignment="Stretch" VerticalAlignment="Center" Grid.Column="1">
                <TextBox.Text>
                <Binding Path="SearchString" UpdateSourceTrigger="PropertyChanged">
                    <Binding.ValidationRules>
                        <ns:SearchStringValidator/>
                    </Binding.ValidationRules>
                </Binding>
                </TextBox.Text>
            </TextBox>
          
            <TextBlock Text="Ping timeout:" Grid.Row="2" Style="{StaticResource TextStyle}" VerticalAlignment="Center"/>
                   
            <StackPanel Orientation="Horizontal" Grid.Row="2" Grid.Column="1">
            <TextBox x:Name="pingTimeout" Width="50" TextAlignment="Right"
                     HorizontalAlignment="Left" VerticalAlignment="Center" 
                     ToolTip="When pinging computers outside the LAN, it can be useful to increase the ping time to avoid timeouts.">
                <TextBox.Text>
                <Binding Path="Pinger.PingTimeOut" UpdateSourceTrigger="PropertyChanged">
                    <Binding.ValidationRules>
                        <ns:NumberValidator/>
                    </Binding.ValidationRules>
                </Binding>
                </TextBox.Text>
            </TextBox>
            <TextBlock Text=" ms" Style="{StaticResource TextStyle}" VerticalAlignment="Center" />
            </StackPanel>
            <CheckBox IsChecked="{Binding Path=FetchHostInfo}" Content="Fetch host info" HorizontalAlignment="Right" VerticalAlignment="Center" Grid.Row="2" Grid.Column="1"/>
            
           </Grid>
                
          <StackPanel Grid.Row="2" Margin="5">
            <TextBlock TextWrapping="Wrap" Style="{StaticResource TextStyle}">
                Use dash (-) to specify a range, and wildcard (*) to search an entire submask. Separate searches with comma (,).   
            </TextBlock>
            <TextBlock Style="{StaticResource TextStyle}" Margin="15,5,0,0"> - Example: <Italic>"192.168.0-2.*, 192.168.5.0-10"</Italic></TextBlock>
          </StackPanel>

          <DockPanel Grid.Row="3" Margin="5">
          <TextBlock Text="Status:" Style="{StaticResource TextStyle}" DockPanel.Dock="Top"/>
          <ListBox x:Name="statusList" ScrollViewer.VerticalScrollBarVisibility="Auto" Grid.Row="2">
            <ListBox.ItemContainerStyle>
                <Style TargetType="ListBoxItem">
                    <Setter Property="FontSize" Value="11"/>
                    <Setter Property="FontFamily" Value="Tahoma"/>
                    <Setter Property="Foreground" Value="#FF4E4E4E"/>
                    <Setter Property="Margin" Value="2"/>
                </Style>
            </ListBox.ItemContainerStyle>
          </ListBox>
          </DockPanel>
          
          <DockPanel Grid.Row="4" Margin="5">
          <TextBlock Text="Replies:" Style="{StaticResource TextStyle}" DockPanel.Dock="Top"/>
          <ListBox x:Name="replyList" ScrollViewer.VerticalScrollBarVisibility="Auto">
            <ListBox.ItemContainerStyle>
                <Style TargetType="ListBoxItem">
                    <Setter Property="FontSize" Value="11"/>
                    <Setter Property="FontFamily" Value="Tahoma"/>
                    <Setter Property="Foreground" Value="#FF4E4E4E"/>
                    <Setter Property="Margin" Value="2"/>
                </Style>
            </ListBox.ItemContainerStyle>
          </ListBox>
          </DockPanel>
          
            <Grid Grid.Row="5">
                <StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
                    <Button x:Name="startBtn" Content="Start" Margin="5" Width="70" Padding="2" IsDefault="True" Click="startBtn_Click"/>
                    <Button x:Name="stopBtn" Content="Stop" Margin="5" Width="70" Padding="2" Click="stopBtn_Click"/>
                </StackPanel>
                <Button Grid.Row="5" x:Name="exitBtn" Content="Exit" Margin="5" Width="70" Padding="2" HorizontalAlignment="Right" Click="exitBtn_Click"/>
            </Grid>
          </Grid>
       </DockPanel>
    </Grid>
</Window>
